package com.example.mapp;

import com.example.entity.ElevatorAppraisal;
import com.example.ext.entity.ExtElevatorAppraisal;
import com.example.mapp.buildSql.AppraisalMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Created by youkun on 2017/9/22.
 */
@Mapper
public interface ElevatorAppraisalMapp {
    @Select(" select * from elevator_appraisal  where id=#{id}")
    ElevatorAppraisal queryById(String id) throws Exception;

    @Select(" select * from elevator_appraisal  where elevator_id=#{elevatorId} order by id desc")
    List<ElevatorAppraisal> queryListById(ExtElevatorAppraisal extElevatorAppraisal) throws Exception;

    @SelectProvider(type = AppraisalMappSql.class,method = "queryList")
    List<ExtElevatorAppraisal> queryListByPartyId(ExtElevatorAppraisal extElevatorAppraisal) throws Exception;


    @Delete(" delete from elevator_appraisal where id=#{id}")
    int deleteById(String id)throws Exception;

    @Update("update elevator_appraisal set " +
            "passenger_phone=#{passengerPhone},evaluate_msg=#{evaluateMsg}," +
            "elevator_id=#{elevatorId},appraisal_time=#{appraisalTime}")
    int update(ElevatorAppraisal elevatorAppraisal) throws Exception;

    @Update("update elevator_appraisal set " +
            "is_feed_back=#{isFeedBack},feed_back_content=#{feedBackContent}" +
            " where id=#{id}")
    int updateFeedBack(ElevatorAppraisal elevatorAppraisal) throws Exception;


    @Insert("insert into elevator_appraisal (passenger_phone,evaluate_msg,elevator_id, appraisal_time, is_like,evaluate_type) " +
            "value (#{passengerPhone},#{evaluateMsg},#{elevatorId},#{appraisalTime},#{isLike},#{evaluateType})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    int add(Map<String, Object> elevatorAppraisal) throws Exception;
}
